//
// Description: 122. 买卖股票的最佳时机 II
// Created by Loading on 2022/6/25.
//

#include <bits/stdc++.h>

using namespace std;

int maxProfit(vector<int> &prices) {
    int max = 0;
    for (int i = 1; i < prices.size(); i++) {
        // 贪心思想，只要赚钱，就累计
        if (prices[i] > prices[i - 1]) {
            max += prices[i] - prices[i - 1];
        }
    }

    return max;
}

int main() {
    vector<int> prices{7, 1, 5, 3, 6, 4};

    int res = maxProfit(prices);

    cout << res << endl;

    return 0;
}
